package com.mike.service.impl;

import com.mike.service.TortoiseService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;

/**
 * @Description
 * @Date 2021/11/16 10:06
 * @Created by mike
 */
@Service
public class TortoiseServiceImpl implements TortoiseService {

    @Override
    public String swim(String place, int timeToWait) {
        int random = new Random().nextInt(timeToWait);
        try {
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "tortoise swimming in : "+place;
    }

    @Override
    public String eat(String foodName, int timeToWait) {
        int random = new Random().nextInt(timeToWait);
        try {
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "tortoise eating : "+foodName;
    }

    @Override
    public String sleep(String place, int timeToWait) {
        int random = new Random().nextInt(timeToWait);
        try {
            Thread.sleep(random);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "tortoise sleeping in : "+place;
    }
}
